package com.lhb.utils;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.10.14 下午 17:33
 */
public class Md5Utils {

    public String md5Salt(String password, String userName) {
        String type = "MD5";
        int interations = 1024;
        ByteSource byteSource = ByteSource.Util.bytes(userName);
        SimpleHash simpleHash = new SimpleHash(type, password, byteSource, interations);
        return simpleHash.toString();
    }

    public static void main(String[] args) {
        String type = "MD5";
        int interations = 1024;
        ByteSource qianfeng2009 = ByteSource.Util.bytes("normal");
        SimpleHash simpleHash = new SimpleHash(type, "normal", qianfeng2009, interations);
        System.out.println(simpleHash.toString());
    }
}
